﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using InputBoxSample;
using PatentApp.Models;
using PatentApp.Data;

namespace PatentApp
{
    public partial class dlgDetails : Form
    {
        public dlgDetails(Produkt updateProduct)
        {
            InitializeComponent();
            using (var session = NHibernateCfg.OpenSession())
            {
                updateProduct = (from prods in session.QueryOver<Produkt>() where prods.ProduktId == updateProduct.ProduktId select prods).SingleOrDefault<Produkt>();
                dgvUpdatePrac.DataSource = updateProduct.Pracownicy;
                txtUpdateCategorie.Text = updateProduct.Kategoria.Nazwa;
            }
            txtUpdateNumOgol.Text = updateProduct.NrOgolny.ToString();
            txtUpdateNumRocz.Text = updateProduct.NrRoczny.ToString();
            if (updateProduct.NrZgloszenia != null)
                txtUpdateZglNum.Text = updateProduct.NrZgloszenia;
            if (updateProduct.NrPatentu != null)
                txtUpdatePatentNum.Text = updateProduct.NrPatentu;
            txtUpdateTitle.Text = updateProduct.Tytul;
            txtUpdateKeyWord.Text = updateProduct.SlowoKluczowe;
            txtUpdateOwner.Text = updateProduct.WlascicielPraw;
            txtUpdateDate.Text = updateProduct.DataZglTworcy.ToShortDateString();
            chkUpdatePlatnosc.Checked = updateProduct.Platnosc;
            if (updateProduct.DataZgloszenia != null)
                txtUpdateZglDate.Text = updateProduct.DataZgloszenia.Value.ToShortDateString();
            if (updateProduct.DataOgloZglo != null)
                txtUpdateOglDate.Text = updateProduct.DataOgloZglo.Value.ToShortDateString();
            if (updateProduct.DataOgloPat != null)
                txtUpdateOglDate2.Text = updateProduct.DataOgloPat.Value.ToShortDateString();
        }

        private void btnUpdateAddPlat_Click(object sender, EventArgs e)
        {

        }

        private void btnUpdateSendOgl_Click(object sender, EventArgs e)
        {

        }

        private void btnUpdateAccept_Click(object sender, EventArgs e)
        {

        }

        private void btnUpdateBack_Click(object sender, EventArgs e)
        {

        }

        private void btnUpdateSendUPRP_Click(object sender, EventArgs e)
        {

        }

        private void grpUpdateTitle_Enter(object sender, EventArgs e)
        {

        }

        private void btnUpdateAccept_Click_1(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Retry;
            this.Close();
        }

        private void btnSlowaKluczowe_Click(object sender, EventArgs e)
        {
            if (new dlgKeyWords().ShowDialog() == DialogResult.OK)
            {
            }
        }

        private void btnUpdateBack_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnPisma_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(Application.StartupPath + "\\Documents\\");
        }

        private void btnKatalog_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(Application.StartupPath + "\\Katalogi\\");
        }

    }
}
